<?php
/**
*商户操作类
*@author :刘旭
**/

class class_businesser extends core {
	/**
	*商户登陆
	*@author：刘旭
	**/
	final static function log_in(){
		$businesser=$_POST['businesser'];
		$pwd=$_POST['pwd'];
		$name=trim($businesser);
		$password=trim($pwd);
		$error=array();

		if(empty($businesser))
		{
			$error['businesser']="用户名不能为空！";
		}

		if(empty($pwd))
		{
			$error['pwd']="密码不能为空！";
		}
		
		//判断用户是否注册
		$user=core::selects('id,username,password',"partner","username='$businesser'");
		if(empty($user))
		{
			$error["exist"]=$businesser."没有注册";
		}
		else
		{
			$user_id=$user[0]->id;
			$pw=$user[0]->password;
			if($pwd!=$pw){
				$error["pwd"]="密码错误,请重新输入";
			}else{
				//成功登陆
				$_SESSION["businesser"]=$name;
				$_SESSION["businesser_id"]=$user_id;
			}
		}
		if(!empty($error)){
			return $error;
		}
		
	}
}
?>